import { defineStore } from 'pinia'
import { ref } from 'vue'
//用户模块 username setUsername removeUsername

export const useUserStore = defineStore(
  "user",
  () => {
    const username = ref("");
    // 修正 setUsername 方法，操作 username 而非 token
    const setUsername = (newName) => {
      username.value = newName;
    };
    const removeUsername = () => {
      username.value = "";
    };
    return { username, setUsername, removeUsername };
  },
  {
    persist: true,
  }
);